import { defineStore } from 'pinia'
import cookieUtil from '@/util/cookie_util'

interface UserState {
  _token: string | null;
  _userInfo: {
    userName: string;
    userLevel: number;
    userNickName: string;
  } | null
}

const useUserStore = defineStore('user', {
  state: (): UserState => {
    return {
      _userInfo: null,
      get _token () {
        return cookieUtil.getCookie('token')
      },
      set _token (val) {
        cookieUtil.setCookie('token', val, 30)
      }
    }
  },
  getters: {
    token: state => state._token
  },
  actions: {
    login () {
    }
  }
})
export default useUserStore
